pub use memory_addr::PhysAddr;
use safe_mmio::fields::ReadWrite;
use zerocopy::{FromBytes, Immutable, IntoBytes, KnownLayout};

use crate::gpio::regs::*;

pub const GPIO_CONTROLLERS: usize = 1; // 1 个 gpio 控制器

#[derive(Clone, Eq, FromBytes, Immutable, IntoBytes, KnownLayout, PartialEq)]
#[repr(C, align(4))]
pub struct GpioController {
    pub data: ReadWrite<GpioPins>,
    pub resv: ReadWrite<u16>,
    pub dir: ReadWrite<GpioPins>,
    pub resv2: ReadWrite<u16>,
}

pub struct GpioSystem {
    pub controllers: [&'static mut GpioController; GPIO_CONTROLLERS],
}

pub const BASE1: PhysAddr = pa!(0x28035000);
